import { createApp } from 'vue'
import App from './App.vue'
import axios from 'axios'
// import * as echarts from 'echarts'

const app = createApp(App)

// 路由
import router from './router/index.js'

// 完全导入elementplus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElIconModules from '@element-plus/icons-vue'
// 统一注册Icon图标
for (const iconName in ElIconModules) {
	if (Reflect.has(ElIconModules, iconName)) {
		const item = ElIconModules[iconName]
		app.component(iconName, item)
	}
}

//store
import store from './store'

//animate.css
import 'animate.css'

// 导入工具类中的storage
import storage from './utils/storage'
//为app实例设置一个自定义的全局属性storage
app.config.globalProperties.$storage = storage

// axios
app.config.globalProperties.$axios = axios

// v-md-editor
// 预览组件以及样式
import VMdPreview from '@kangc/v-md-editor/lib/preview'
import '@kangc/v-md-editor/lib/style/preview.css'

// VuePress主题以及样式（这里也可以选择github主题）
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js'
import '@kangc/v-md-editor/lib/theme/style/vuepress.css'

// Prism
import Prism from 'prismjs'

// 代码高亮
import 'prismjs/components/prism-json'

// 选择使用主题
VMdPreview.use(vuepressTheme, {
	Prism,
})

// 重写ElementMessage防止弹多个
import { message } from './utils/resetMessage.js'

app.use(VMdPreview)
app.use(router)
app.use(store)
app.use(ElementPlus)
app.config.globalProperties.$msg = message // 挂载
app.mount('#app')
